<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>小鱼ADMIN</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/public/static/css/font.css">
    <link rel="stylesheet" href="/public/static/css/bgadmin.css">
    <link href="/public/static/lib/address/css/city-picker.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/public/static/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/public/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/public/static/js/bgadmin.js"></script>
    <script type="text/javascript" src="/public/static/js/jquery.form.js"></script>  
</head>

<body>
    <div class="bg-body">
        <form  action="#" method="post" id="basicCustomer" class="layui-form">
            <input type="hidden" name="customer_code" id="customer_code" value="{$customerData.customer_code}">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">
                        客户编码：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" value="{$customerData.customer_code}" disabled class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        <span class="bg-red">*&nbsp;&nbsp;</span>客户姓名：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" value="{$customerData.name}" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                {if condition="($username eq 'admin') OR ($priv['display_phone'] eq 'Y')"}
                <div class="layui-inline">
                    <label class="layui-form-label">
                        <span class="bg-red">*&nbsp;&nbsp;</span>客户手机：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="phone" name="phone" value="{$customerData.phone}" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        客户电话：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="telephone" name="telephone" value="{$customerData.telephone}" autocomplete="off" class="layui-input">
                    </div>
                </div>
                {/if}
                <div class="layui-inline">
                    <label class="layui-form-label">
                        客户性别：
                    </label>
                    <div class="layui-input-inline">
                        <select name="sex" id="sex" autocomplete="off" class="layui-input">
                            <option value="">请选择</option>
                            {$customerData.option}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        客户年龄：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="age" name="age" value="{$customerData.age}" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        会员等级：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="integral" name="integral" disabled value="{$customerData.member_level}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        当前积分：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="integral" name="integral" disabled value="{$customerData.integral}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        最后回访：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="last_call_time" name="last_call_time" disabled value="{$customerData.last_call_time}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        最后下单：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="last_order_time" name="last_order_time" disabled value="{$customerData.last_order_time}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        开单次数：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="order_num" name="order_num" disabled value="{$customerData.order_num}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        签收次数：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="sign_num" name="sign_num" disabled value="{$customerData.sign_num}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        会员类型：
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="customer_type" name="customer_type" disabled value="{$customerData.customer_type}" autocomplete="off" class="layui-input layui-bg-gray">
                    </div>
                </div>
            </div>
            {if condition="$customerData['transfer_note']"}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">
                    转交备注：
                </label>
                <div class="layui-input-block" style="">
                    <input class="layui-input" name="transfer_note" value="{$customerData.transfer_note}" disabled style="width:50%">
                </div>
            </div>
            {/if}
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="bg-red">*&nbsp;&nbsp;</span>所在地区：
                </label>
                <div class="layui-input-block">
                    <div style="position: relative;">
                        <input id="city-picker3" style="width:50%;line-height:30px;" class="form-control" name="location_address" readonly type="text" value="{$address.province}/{$address.city}/{$address.area}" data-toggle="city-picker">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">
                    详细地址：
                </label>
                <div class="layui-input-block" id="address_select" style="">
                    <input class="layui-input"  placeholder="建议您如实填写详细收货地址，例如街道名称，门牌号码，楼层和房间号等信息" name="address_details" value="{$address.address_details}" lay-verify="required" style="width:50%">
                </div>
            </div>
            {if condition="$customerData['data_task'] eq null"}
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <a class="layui-btn layui-btn-normal" onclick="addDataTask();"><i class="layui-icon">&#xe654;</i>加入数据任务</a>
            </div>
            {/if}
        </form>
    </div>

</body>
<!-- <script type="text/javascript" src="/public/static/crm/js/customer/editCustomer.js"></script> -->
<script src="/public/static/lib/address/js/city-picker.data.js"></script>
<script src="/public/static/lib/address/js/city-picker.js"></script>
<script src="/public/static/lib/address/js/main.js"></script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#brithday'
        });

        laydate.render({
            elem: '#callbacktime',
            type: 'datetime'
        });
    });


    // var url = 
    function loadIframe (id, url) {
        if ($('#'+id).attr('src') == "") {
            $('#'+id).attr('src', url);
        }
    }

    var layer = layui.layer;
    var layedit = layui.layedit;
    var ajax_option_basic={  
        url:"updateCustomer",
        success:function(data){  
            var result = $.parseJSON(data); 
            if (result.success) {  
                layer.alert(result.msg, {icon: 6}, function(index){
                    layer.close(index);
                });
            } else {  
                layer.alert(result.msg, {icon: 5}, function(index){
                    layer.close(index);
                });
            }
        }
    };


    layui.use(['form', 'layedit'], function(){
        var form = layui.form
        ,layedit = layui.layedit;

        form.on('submit(saveCustomer)', function(data){
            $('#basicCustomer').ajaxSubmit(ajax_option_basic);
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });



    function addDataTask() {
        var customer_code = $('#customer_code').val();
        var customer_name = $('#name').val();
        bg_admin_show('加入数据任务','./addDataTask.html?customer_code='+customer_code+'&customer_name='+customer_name,750,450)
    }
	
	var exten = "1000";
	function call1(customer_code){
		$.ajax({
			type : 'post',
			url : '/index.php/crm/Pbx/call1',
			data : {src_exten:exten,customer_code:customer_code},
			dataType : 'json',
			success : function (result) {
				if (result.success) {  
					
				} else {  
					
				}
			}
		})
		
	}
	

</script>
</html>
